<?php
	$Search = "Hammer";
?>
<h1>Search results for '<?php echo $Search; ?>' in Category 'Title'</h1>

<table width="100%" border="1">
	<tr>
		<th align='left' style='vertical-align: top;'>Title</th>
		<th>Year</th>
		<th>Box Art</th>
	</tr>
<?php
	require_once("../imdb/imdb.class.php");
	$IMDB = new IMDB();
	//The TV search type actually searches based on episode names, not tv series names.
	//If you wish to search by tv series name you should be using SEARCH_TYPE_TITLE.
	$Search = $IMDB->Search($Search, IMDB::SEARCH_TYPE_TITLES);
	$Results = $Search->getResults();
	foreach ($Results as $Result) {
		echo "<tr>";
		echo "<td><a href='" , $Result->getURL() . "'>" . $Result->getTitle() . "</a>";
		$Alts = $Result->getAlternates();
		if ($Alts) {
			echo "<table border='1' style='margin: 5px; margin-left: 20px;'>";
			echo "<tr>
				<th align='left'>Alternate Title</th>
				<th>Country</th>
				<th>Description</th>
				</tr>";
			foreach ($Alts as $Alt) {
				echo "<tr>";
				echo "<td>" . $Alt->getTitle() . "</td>";
				if ($Alt->getCountry())
					echo "<td>" . $Alt->getCountry() . "</td>";
				if ($Alt->getDescription())
					echo "<td>" . $Alt->getDescription() . "</td>";
				echo "</tr>";
			}
			echo "</table>";
		}
		echo "</td>";
		echo "<td align='center'>"	. $Result->getYear() . "</td>";
		$Img = $Result->getImg(50, 50);
		if ($Img != "")
			echo "<td align='center'><img src='$Img' alt='Box Art' /></td>";
		else
			echo "<td>&nbsp;</td>";
		
		echo "</tr>";
	}
?>
</table>